package com.pavlinic.mylisp.specialForms;


import com.pavlinic.mylisp.EvaluationContext;
import com.pavlinic.mylisp.Expression;
import com.pavlinic.mylisp.GlobalEvaluationContext;
import com.pavlinic.mylisp.ListExpression;
import com.pavlinic.mylisp.SymbolExpression;

public class Def {
  public static Expression evaluateDef(ListExpression listExpression, EvaluationContext evaluationContext) {
    final SymbolExpression bindingSymbol = (SymbolExpression) listExpression.get(1);
    final String bindingName = bindingSymbol.getValue();
    final Expression boundExpression = listExpression.get(2).evaluate(evaluationContext);
    
    GlobalEvaluationContext.getInstance().bind(bindingName, boundExpression);
    return bindingSymbol;
    
  }

}
